<template>
	<view>
		<!-- tabbar -->
		<view class="find-title">
			<view class="title-item" v-for="(item,index) in findList" :key="index" @tap="getNew(index)">
				{{item}}
				<view class="line" v-show="currentIndex==index">
					
				</view>
			</view>
		</view>
	 <!-- 文章列表 -->
	 <view class="article" v-if="currentIndex==0">
	 	<view class="article-item" v-for="item in articleList" :key="item.id" @tap="goInfo(item.id)">
			<image :src="item.coverImg" mode=""></image>
			<view class="author">
				{{item.author}}
			</view>
			<view class="article-bt">
				<view class="watcher">
					<image src="../../static/icons/watch.png" mode=""></image>
					<view class="watchers">
						{{item.viewCount}}
					</view>
				</view>
				<view class="collect">
					<image src="../../static/icons/collect1.png" mode=""></image>
				</view>
			</view>
	 	</view>
	 </view>
	 <!-- 品牌列表 -->
	 <view class="brand" v-if="currentIndex==1">
	 	<view class="brand-item" v-for="item in brandList" :key="item.id">
	 		<image :src="item.bigPic" mode=""></image>
			<view class="brand-box">
				<view class="brand-title">
					{{item.name}}
				</view>
				<view class="brand-desc">
					{{item.brandStory}}
				</view>
			</view>
	 	</view>
	 </view>
	</view>
</template>

<script>
	import {find,Article,ArticleInfo} from"../../utils/find/index.js"
	export default {
		data() {
			return {
				findList:['精选文章','品牌列表'],
				currentIndex:0,
				articleList:[],
				brandList:[]
			}
		},
		methods: {
			getNew(index){
			this.currentIndex=index
			if(this.currentIndex==1){
				const start=1
				const limit =6
				find(
					start,
					limit
				).then(res=>{
					console.log(res)
					this.brandList=res.data.rows
				})
			} else{
				Article('1','5').then(res=>{
					// console.log(res)
					this.articleList=res.data.rows
					
				})
			}
			},
			goInfo(id){
				
				
				uni.navigateTo({
					url:"/pages/find/articleInfo/articleInfo?id="+id
				})
			}
		},
		onLoad(){
			
			Article('1','5').then(res=>{
				// console.log(res)
				this.articleList=res.data.rows
			})
		}
	}
</script>

<style scoped lang="scss">
.find-title{
		display: flex;
	    justify-content: center;
	    align-items: center;
		background-color: #354E44;
		.title-item{
			line-height: 88rpx;
			    // box-sizing: border-box;
			    padding: 10rpx 0;
			    margin: 0 10rpx;
				color: #fff;
				
		}
		.line{
			
			width: 100%;
			height: 5rpx;
			background-color: #fff;
			transition: all .3s;
		}
}
	
.article{
	margin-top: 100rpx;
	.article-item{
		position: relative;
		    width: 674rpx;
		    height: 482rpx;
		    border-radius: 24rpx;
		    background-color: #fff;
		    margin: 28rpx auto;
		    overflow: hidden;
			image{
				width: 100%;
				height: 382rpx;
				display: block;
				    // position: absolute;
				    top: 0;
				    left: 0;
				   
			}
			.author{
				color: #fff;
				    font-size: 30rpx;
				    line-height: 42rpx;
				position: absolute;
				top: 50%;
			}
			.article-bt{
				position: absolute;
				width: 90%;
				
				display: flex;
				justify-content: space-between;
				align-items: center;
				height: 100rpx;
				bottom: 0;
				left: 50%;
				transform: translateX(-50%);
				.watcher{
					width:116rpx;
					height: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					image{
						width: 40rpx;
						height: 40rpx;
						
					}
					.watchers{
						color: #333;
						font-size: 20rpx;
						
					}
				}
				.collect{
					width: 40rpx;
					height: 40rpx;
					image{
						width: 40rpx;
						height: 40rpx;
					}
				}
			}
	}
}
.brand-item{
	width: 90%;
	height: 620rpx;
	margin: 30rpx auto;
	background: #fff;
	    border-radius: 4px;
	    overflow: hidden;
		image{
			width: 100%;
			height: 480rpx;
		}
		.brand-box{
			margin: 30rpx;
			    background: #fff;
			    border-radius: 8rpx;
			    overflow: hidden;
				.brand-title{
					font-size: 32rpx;
					    line-height: 44rpx;
					    color: #3e3e3e;
				}
				.brand-desc{
					font-size: 22rpx;
					    color: #b1b1b1;
					    line-height: 30rpx;
					    white-space: nowrap;
					    overflow: hidden;
					}
				}
		}

</style>
